git pull
gradle clean
gradle -I init.gradle build -x test 

cd ~/app/azkaban/azkaban-exec-server
sh bin/shutdown-exec.sh || true
echo 'azkaban-exec-server has be killed'

cd ~/app/azkaban/azkaban-web-server
sh bin/shutdown-web.sh || true
echo 'azkaban-web-server has be killed'

rm -rf ~/app/azkaban/*
echo 'clear ~/app/azkaban'

mv /root/ws/azkaban/azkaban-web-server/build/distributions/*.zip ~/app/azkaban/azkaban-web-server.zip
mv /root/ws/azkaban/azkaban-exec-server/build/distributions/*.zip ~/app/azkaban/azkaban-exec-server.zip

echo 'moving zip to target directory'

cd  ~/app/azkaban/ && unzip ~/app/azkaban/azkaban-web-server.zip
mv azkaban-web-server-* azkaban-web-server

cd  ~/app/azkaban/ && unzip ~/app/azkaban/azkaban-exec-server.zip
mv azkaban-exec-server-* azkaban-exec-server

cd ~/app/azkaban/azkaban-exec-server
sh bin/start-exec.sh
echo 'start azkaban-exec-server success.'

sleep 10
cd ~/app/azkaban/azkaban-exec-server/ && curl -G "localhost:$(<./executor.port)/executor?action=activate" && echo

cd ~/app/azkaban/azkaban-web-server
sh bin/start-web.sh
echo 'start azkaban-web-server success.'


echo '===================='
echo " tailf  ~/app/azkaban/azkaban-exec-server/logs/azkaban-execserver.log"
echo " tailf  ~/app/azkaban/azkaban-web-server/logs/azkaban-webserver.log"
